$(document).ready(function () {
    var pageSize = 10
    $.get(`/getGoodlist`, res => {
        res = JSON.parse(res)
        var data = res.data
        console.log(res.data)
        new Page('page-wrap', {
            pageData: {
                total: data.length,
                pageSize
            },
            fn(currentPage) {
                var arr = data.slice((currentPage - 1) * pageSize, currentPage * pageSize)
                var str = ''
                arr.forEach(item => {
                    str +=
                        `<div class="c-goods-item"><a href="/product.html?id=${item.id}">
                                <div class="c-goods-item-top">
                                    <div class="c-goods-item-img"><img
                                            src="${item.img}" alt=""></div>
                                    <div class="c-goods-item-logo"><img src="${item.logo}" alt=""></div>
                                    <div class="c-goods-item-tag"><img src="./images/1653875824633_85x85_90.png" alt="">
                                    </div>
                                    
                                </div>
                                <div class="c-goods-item-bottom">
                                    <div class="c-goods-item-price">
                                        <div class="price-label"><span>特卖价</span></div>
                                        <div class="sale-price"><span>¥</span>${item.price}</div>
                                        <div class="market-price"><span>¥</span>${item.marketp}</div>
                                        <div class="discount"><span></span>${item.discout}</div>
                                    </div>
                                    <div class="c-goods-item-name">${item.title}</div>
                                </div>
                            </a>
                        </div>`

                })
                $('.c-goods-list-inner').html(str)
            }
        })

    })


var usercenterbtn = document.querySelector(`.wp-more`)
usercenterbtn .onclick=function(){
   location.href = "usercenter.html"
}


window.onscroll = function () {
    var t = document.documentElement.scrollTop || document.body.scrollTop
console.log(t)
    var ullis = document.querySelector(`.mian-nav`)
    if (t > 100) {
        ullis.style.position = `fixed`;
        ullis.style.top = `0px`;
        ullis.style.zIdex = `999`
        ullis.style.backgroundColor = `white`
        ullis.style.width = `100%`


    } else {
        ullis.style.position = `static`
    }}})